<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>待审核语料库</title>
    <link rel="stylesheet" href="../../component/pear/css/pear.css" />
</head>
<body class="pear-container">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="javascript:void(0);">
                <div class="layui-form-item">
                    <label class="layui-form-label">忽略词</label>
                    <div class="layui-input-block">
                        <textarea maxlength="2000" id="interpunction" name="interpunction" lay-verify="required" placeholder="请输入忽略词，多个用|分割。" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">敏感词</label>
                    <div class="layui-input-block">
                        <textarea maxlength="2000" id="sensitiveword" name="sensitiveword" lay-verify="required" placeholder="请输入敏感词，多个用|分割。" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="save"> 保存 </button>
                        <button type="reset" class="layui-btn layui-btn-primary"> 重置 </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="../../component/layui/layui.js"></script>
    <script src="../../component/pear/pear.js"></script>
    <script>
        layui.use(['layer', 'form', 'jquery', 'http', 'loading', 'toast'], function () {
            let layer = layui.layer;
            let form = layui.form;
            let $ = layui.jquery;
            let http = layui.http;
            let loading = layui.loading;
            let toast = layui.toast;

            loading.Load(5, '加载中...');
            http.ajax({
                url: '/YuLiaoK/GetConfig',
                type: 'get'
            }).done(function (res) {               
                $.each(res.result, function (index, item) {
                    if (item.key == 'interpunction')
                        $('#interpunction').val(item.value);
                    else if (item.key == 'sensitiveword')
                        $('#sensitiveword').val(item.value);
                });
            }).always(function () {
                loading.loadRemove(500);
            });


            form.on('submit(save)', function (data) {
                loading.Load(5, '请稍等...');
                var postdata = [
                    { key: 'interpunction', value: data.field.interpunction },
                    { key: 'sensitiveword', value: data.field.sensitiveword }
                ]
                http.ajax({
                    url: '/YuLiaoK/SaveConfig',
                    data: JSON.stringify(postdata)
                }).done(function (data) {
                    toast.success({ title: "提示", message: "保存成功" })
                }).always(function () {
                    loading.loadRemove(500);
                });

                return false;
            });
        })
    </script>
</body>
</html>
